<?php
/**
 * 
 * Vista de las sedes
 * @author Joan Muñoz
 * 
 */
require_once('../../config.php');
require PATH_ADMIN . 'session.php';
define('MENU_ACTIVE', 'sedes');
$js_arr = array('sedes/sedes.js');
$css_arr = array('sedes/sedes.css');
require_once PATH_ADMIN . 'layout/header.php';

// Consulta de las sedes
mysql_select_db(DB_NAME, $conexion);
$query = sprintf("SELECT * FROM sede ORDER BY id DESC");
$sedes = mysql_query($query) or die(mysql_error());
?>

    <div class="container">
        
        <p><button class="btn btn-primary" id="btn_create">Crear Sede</button></p>
        
        <!-- FORMULARIO PARA CREAR UN EVENTO -->
        <form action="javascript:void(0);" method="post" class="well" id="frm_insert">
            <input type="hidden" name="sede_id" id="sede_id" value="" />
            <table class="table table-bordered">
                <tr>
                    <td class="control-group">
                        <label><strong>Sede:</strong></label>
                        <input type="text" name="sede" id="input_sede" value="" />
                        <span class="help-inline">Por favor llene este campo.</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table class="clear table-bordered table-striped" id="localidad-table">
                            <tr>
                                <th>Localidad:</th>
                                <th>Costo:</th>
                            </tr>
                            <tr>
                                <td class="control-group">
                                    <input type="text" name="locacion[]" class="locacion" value="" /><br />
                                    <span class="help-inline">Por favor llene este campo.</span>
                                </td>
                                <td class="control-group">
                                    <input type="text" name="precio[]" class="precio" value="" /><br />
                                    <span class="help-inline">Por favor llene este campo.</span>                                 
                                </td>
                                <td>
                                  <a href="javascript:void(0);" class="add" id="btn_add_location" title="Agregar Localidad"></a>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                  <td>
                      <button class="btn btn-success" id="btn_save">Guardar</button>
                      <button class="btn btn-danger" id="btn_cancel">Cancelar</button>
                  </td>
              </tr>
            </table>
        </form>
        
        <div class="alert fade in">
          <a class="close" href="#" data-dismiss="alert">×</a>
          <div class="alert_message"></div>
        </div>
        
        <table class="table table-bordered table-striped" id="venues_table">
            <tr>
                <th>#</th>
                <th>Sede</th>
                <th>Opciones</th>
            </tr>
            <?php while ($sede = mysql_fetch_assoc($sedes)) { ?>
            <tr>
                <td><?php echo $sede['id']; ?></td>
                <td><?php echo $sede['nombre']; ?></td>
                <td>
                    <a href="<?php echo $sede['id']; ?>" class="edit edit_venue"></a>
                    <a href="<?php echo $sede['id']; ?>" class="delete delete_venue"></a>
                </td>
            </tr>
            <?php } // end while ($row = mysql_fetch_assoc($sedes)) ?>
        </table>
        
    </div> <!-- end of .container -->

<?php 
require_once PATH_ADMIN . 'layout/footer.php';
mysql_free_result($sedes);
mysql_close($conexion);
?>